package com.mybatis.message;

import lombok.Getter;

/**
 * @desc: 全局状态码和msg
 * @projectName: mybatis-generator-parent
 * @author: xhs
 * @date: 2023-7-22 022 14:28
 * @version: JDK 1.8
 */
@Getter
public enum Result {

    /**
     * 登录相关的状态码 500开头
     */
    NOT_LOGIN_ERROR(401, "未登录"),
    LOGIN_ERROR(5001, "登录失败"),
    LOGIN_USER_ERROR(5002, "账号密码错误"),
    LOGIN_NOT_EXISTENT(5003, "账号不存在"),
    LOGIN_EXISTENT(5004, "账号已存在"),
    PHONE_EXISTENT(5005, "手机号已存在"),
    JOB_NUMBER_EXISTENT(5006, "工号已存在"),
    PASSWORD_INCONSISTENCY(5007, "二次输入的密码不一致"),
    REGISTER_ERROR(5008, "注册失败"),
    OLD_PWD_ERROR(5009, "旧密码错误"),
    ROLE_ERROR(6001, "角色异常"),
    PERMISSION_ERROR(6002, "权限异常"),

    /**
     * 成功的状态码 0
     */
    SUCCESS(0, "操作成功"),
    DATABASE_CONNECTION_SUCCESS(0, "数据库连接成功"),
    GENERATOR_CODE_SUCCESS(0, "代码生成成功"),
    LOGIN_SUCCESS(0, "登录成功"),
    ADD_SUCCESS(0, "新增成功"),
    DEL_SUCCESS(0, "删除成功"),
    UPD_SUCCESS(0, "更新成功"),
    QUERY_SUCCESS(0, "查询成功"),
    REGISTER_SUCCESS(0, "注册成功"),
    DOWNLOAD_FILE_SUCCESS(0, "下载成功"),
    COPY_SUCCESS(0, "拷贝成功"),
    EXPORT_SUCCESS(0, "导出成功"),
    UPLOAD_FILE_SUCCESS(0, "文件上传成功"),
    ZIP_FILE_SUCCESS(0, "文件压缩成功"),

    /**
     * 失败的状态码 9开头 4位
     */
    ERROR(9999, "系统异常"),
    DATABASE_CONNECTION_ERROR(9999, "数据库连接失败"),
    GENERATOR_CODE_ERROR(9999, "代码生成失败"),
    ADD_ERROR(9998, "新增失败"),
    DEL_ERROR(9997, "删除失败"),
    UPD_ERROR(9996, "更新失败"),
    DATA_NOT_EXISTENT(9995, "数据不存在"),

    /**
     * 文件操作失败的状态码 8开头 4位
     */
    DOWNLOAD_FILE_ERROR(8881, "下载文件异常"),
    EXPORT_ERROR(8882, "导出失败"),
    UPLOAD_FILE_ERROR(8883, "文件上传异常"),

    /**
     * 角色相关的错误状态码 7开头 4位
     */
    ROLE_NOT_EXISTENT(7771, "角色不存在");
    /**
     * 状态码
     */
    private Integer code;

    /**
     * msg消息
     */
    private String msg;

    Result(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Result formatMsg(String str) {
        this.msg = str;
        return this;
    }
}
